const KoaRouter = require("@koa/router");
const {
  create,
  list,
  detail,
  update,
  remove,
} = require("../controller/moment.controller");
const { verifyAuth } = require("../middleware/login.middleware");
const { verifyPermission } = require("../middleware/permission.middleware");

const momentRouter = new KoaRouter({ prefix: "/moment" });

momentRouter.post("/", verifyAuth, create);

momentRouter.get("/", list);

momentRouter.get("/:momentId", detail);
// 3.删: 删除动态
// momentRouter.delete('/:momentId', verifyAuth, verifyMomentPermission, remove)
// 4.改: 修改动态
// 验证: 登录的用户才能修改动态
// momentRouter.patch('/:momentId', verifyAuth, verifyMomentPermission, update)

momentRouter.delete("/:momentId", verifyAuth, verifyPermission, remove);

momentRouter.patch("/:momentId", verifyAuth, verifyPermission, update);

module.exports = momentRouter;
